using System;
using UnityEngine;

[RequireComponent(typeof(LineRenderer))]
public class CircleRenderer : MonoBehaviour
{
	public int segments = 50;

	public LineRenderer line;

	private void Start()
	{
		if (line == null)
		{
			line = base.gameObject.GetComponent<LineRenderer>();
		}
	}

	public void SetCircle(Vector3 position, float radius)
	{
		base.transform.position = position + Vector3.up * 100f;
		line.positionCount = segments + 1;
		line.useWorldSpace = false;
		CreatePoints(radius);
	}

	private void CreatePoints(float radius)
	{
		float num = 20f;
		for (int i = 0; i < segments + 1; i++)
		{
			float x = Mathf.Sin((float)Math.PI / 180f * num) * radius;
			float z = Mathf.Cos((float)Math.PI / 180f * num) * radius;
			line.SetPosition(i, new Vector3(x, 0f, z));
			num += 360f / (float)segments;
		}
	}
}
